import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '文件编号',
    align: "center",
    dataIndex: 'number'
  },
  {
    title: '文件名称',
    align: "center",
    dataIndex: 'name'
  },
  {
    title: '文件版本',
    align: "center",
    dataIndex: 'version'
  },
  {
    title: '发布时间',
    align: "center",
    dataIndex: 'publishDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '实时时间',
    align: "center",
    dataIndex: 'executeDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '发布范围',
    align: "center",
    dataIndex: 'radius'
  },
  {
    title: '附件',
    align: "center",
    dataIndex: 'attachments',
  },
  {
    title: '状态',
    align: "center",
    dataIndex: 'status_dictText'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "文件编号",
    field: 'number',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "文件名称",
    field: 'name',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "状态",
    field: 'status',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "normalOrStop"
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '文件编号',
    field: 'number',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入文件编号!'},
             ];
    },
  },
  {
    label: '文件名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入文件名称!'},
             ];
    },
  },
  {
    label: '文件版本',
    field: 'version',
    component: 'Input',
  },
  {
    label: '发布时间',
    field: 'publishDate',
    component: 'DatePicker',
  },
  {
    label: '实时时间',
    field: 'executeDate',
    component: 'DatePicker',
  },
  {
    label: '发布范围',
    field: 'radius',
    component: 'Input',
  },
  {
    label: '附件',
    field: 'attachments',
    component: 'JUpload',
    componentProps:{
     },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入附件!'},
             ];
    },
  },
  {
    label: '状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "normalOrStop"
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  number: {title: '文件编号',order: 0,view: 'text', type: 'string',},
  name: {title: '文件名称',order: 1,view: 'text', type: 'string',},
  version: {title: '文件版本',order: 2,view: 'text', type: 'string',},
  publishDate: {title: '发布时间',order: 3,view: 'date', type: 'string',},
  executeDate: {title: '实时时间',order: 4,view: 'date', type: 'string',},
  radius: {title: '发布范围',order: 5,view: 'text', type: 'string',},
  attachments: {title: '附件',order: 6,view: 'file', type: 'string',},
  status: {title: '状态',order: 7,view: 'radio', type: 'string',},
};
